<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.5: http://docutils.sourceforge.net/" />
<title>The XML File Specification</title>
<link rel="stylesheet" href="doc.css" type="text/css" />
</head>
<body>
<div class="document">
<div class="navigation navigation-header container">
<span class="previous">Previous: <a class="reference" href="maps.html" title="Maps">Maps</a></span><span class="next">Next: <a class="reference" href="xml_file_contents.html" title="XML file contents">XML file contents</a></span><span class="breadcrumbs"><a class="reference" href="index.html" title="Programming Guide">Programming Guide</a> » <a class="reference" href="tiled_maps.html" title="Tiled maps">Tiled maps</a> » The XML ...</span></div>
<h1 class="title">The XML File Specification</h1>

<p>Assuming the following XML file called &quot;example.xml&quot;:</p>
<pre class="py-doctest">
&lt;?xml version=<span class="py-string">&quot;1.0&quot;</span>?&gt;
&lt;resource&gt;
  &lt;requires file=<span class="py-string">&quot;ground-tiles.xml&quot;</span> namespace=<span class="py-string">&quot;ground&quot;</span> /&gt;

  &lt;rectmap id=<span class="py-string">&quot;level1&quot;</span>&gt;
   &lt;column&gt;
    &lt;cell tile=<span class="py-string">&quot;ground:grass&quot;</span> /&gt;
    &lt;cell tile=<span class="py-string">&quot;ground:house&quot;</span>&gt;
      &lt;property type=<span class="py-string">&quot;bool&quot;</span> name=<span class="py-string">&quot;secretobjective&quot;</span> value=<span class="py-string">&quot;True&quot;</span> /&gt;
    &lt;/cell&gt;
   &lt;/column&gt;
  &lt;/map&gt;
&lt;/resource&gt;</pre>
<p>You may load that resource and examine it:</p>
<pre class="py-doctest">
<span class="py-prompt">&gt;&gt;&gt; </span>r = load(<span class="py-string">'example.xml'</span>)
<span class="py-prompt">&gt;&gt;&gt; </span>map = r[<span class="py-string">'level1'</span>]</pre>
<p>and then, assuming that level1 is a map:</p>
<pre class="py-doctest">
<span class="py-prompt">&gt;&gt;&gt; </span>scene = cocos.scene.Scene(map)</pre>
<p>and then either manually select the tiles to display:</p>
<blockquote>
<pre class="doctest-block">
&gt;&gt;&gt; map.set_view(0, 0, window_width, window_height)
</pre>
</blockquote>
<p>or if you wish for the level to scroll, you use the ScrollingManager:</p>
<pre class="py-doctest">
<span class="py-prompt">&gt;&gt;&gt; </span><span class="py-keyword">from</span> cocos <span class="py-keyword">import</span> layers
<span class="py-prompt">&gt;&gt;&gt; </span>manager = layers.ScrollingManager()
<span class="py-prompt">&gt;&gt;&gt; </span>manager.add(map)</pre>
<p>and later set the focus with:</p>
<pre class="py-doctest">
<span class="py-prompt">&gt;&gt;&gt; </span>manager.set_focus(focus_x, focus_y)</pre>
<p>See the section on <a class="reference" href="controlling_map_scrolling.html">controlling map scrolling</a> below for more detail.</p>
<div class="navigation navigation-footer container">
<span class="previous">Previous: <a class="reference" href="maps.html" title="Maps">Maps</a></span><span class="next">Next: <a class="reference" href="xml_file_contents.html" title="XML file contents">XML file contents</a></span><span class="breadcrumbs"><a class="reference" href="index.html" title="Programming Guide">Programming Guide</a> » <a class="reference" href="tiled_maps.html" title="Tiled maps">Tiled maps</a> » The XML ...</span></div>
</div>
</body>
</html>
